<template>
  <div>
    <input type="text" placeholder="title" v-model="params.title">
    <textarea v-model="params.content"></textarea>
    <el-button type="primary" @click="add()">确 定</el-button>
  </div>
</template>

<script type="text/ecmascript-6">
  import { mapGetters } from 'vuex'
  import { FORUM_INITIALIZE, FORUM_RESULT, THREAD_ADD } from '../../../store/mutation-types'
  export default {
    data () {
      return {
        params: {
          title: '',
          content: ''
        }
      }
    },
    computed: mapGetters({
      result: FORUM_RESULT
    }),
    mounted: function () { // 每次路由到这个页面会自动初始化返回的结果
      this.$store.dispatch(FORUM_INITIALIZE)
    },
    methods: {
      add () {
        this.params.threadId = 1
        this.params.nickName = 'asd'
        this.params.threadGroup = 'GOSSIP'
        this.params.status = 'GENERAL'
        console.log(this.params)
        this.$store.dispatch(THREAD_ADD)
      }
    }
  }
</script>

<style lang="stylus" rel="stylesheet/stylus">
  @import "fThreadReply.styl";
</style>
